package com.teacher.pojo.enums.items;

import java.math.BigDecimal;

public enum MoralEducationType {
    /**
     * 10->校级优秀团干 20->校级优秀团员
     * 30->院级优秀党员 40->院级优秀团干 50->院级优秀团员 60->院级优秀学生干部
     * ->70 其它
     */
    A(10, new BigDecimal(3), "校级优秀团干"), B(20, new BigDecimal(3), "校级优秀团员"),
    C(30, new BigDecimal(1), "院级优秀党员"), D(40, new BigDecimal(1), "院级优秀团干"),
    E(50, new BigDecimal(1), "院级优秀团员"),
    F(60, new BigDecimal(1), "院级优秀学生干部"), G(70, new BigDecimal("1.5"), "院级优秀学生干部");
    private Integer code;
    private BigDecimal grades;
    private String name;

    MoralEducationType(Integer code, BigDecimal grades, String name) {
        this.grades = grades;
        this.code = code;
        this.name = name;
    }

    /**
     * 通过code拿到名称
     *
     * @param type
     * @return
     */
    public static String getNameByCode(Integer type) {
        for (MoralEducationType eType : MoralEducationType.values()) {
            if (eType.code.equals(type)) {
                return eType.name;
            }
        }
        return "0";
    }

    /**
     * 通过code拿到分数
     *
     * @param type
     * @return
     */
    public static BigDecimal getGradesByCode(Integer type) {
        for (MoralEducationType eType : MoralEducationType.values()) {
            if (eType.code.equals(type)) {
                return eType.grades;
            }
        }
        return new BigDecimal(0);
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public BigDecimal getGrades() {
        return grades;
    }

    public void setGrades(BigDecimal grades) {
        this.grades = grades;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }
}
